﻿using System;
using System.Diagnostics.Contracts;

namespace Isuka.Iteration
{
    public partial interface IIterable<out TIterator>
        where TIterator : IIterator
    {
        /// <summary>
        /// 開始位置
        /// </summary>
        /// <returns></returns>
        TIterator Begin();

        /// <summary>
        /// 終了位置
        /// null を返す場合もある
        /// </summary>
        /// <returns></returns>
        TIterator End();
    }

    #region IIterable contract binding
    [ContractClass(typeof(IIterableContract<>))]
    public partial interface IIterable<out TIterator> { }

    [ContractClassFor(typeof(IIterable<>))]
    abstract class IIterableContract<TIterator> : IIterable<TIterator>
        where TIterator : IIterator
    {
        #region IIterable<TIterator> メンバー

        public TIterator Begin()
        {
            Contract.Ensures(Contract.Result<TIterator>() != null);
            throw new NotImplementedException();
        }

        public TIterator End()
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    #endregion

}
